package com.itmake.sample.mqtt.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * mqtt 配置
 *
 * @author Amjacks
 * @since 2023/08/10
 */
@Configuration
@ConfigurationProperties(prefix = "config.mqtt")
public class MqttConfig {

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * mqtt server地址
     */
    private String url;

    /**
     * true：重连后清除session
     */
    private Boolean cleanSession;

    /**
     * 连接超时
     */
    private Integer timeout;

    /**
     * 心跳间隔
     */
    private Integer keepalive;

    /**
     * 消息发出后，等待回复的数量，参数随并发量、网络延迟提高而变大
     */
    private Integer maxInflight;

    /**
     * 消息质量
     * 0：表示的是订阅者没收到消息不会再次发送，消息会丢失
     * 1：表示的是会尝试重试，一直到接收到消息，但这种情况可能导致订阅者收到多次重复消息
     * 2：多了一次去重的动作，确保订阅者收到的消息有一次
     */
    private Integer qos;

    /**
     * 监听-客户端 id
     */
    private String clientInId;

    /**
     * 发送-客户端 id
     */
    private String clientOutId;

    /**
     * 生产者 topic 数组
     */
    private Map<String, String> producer;

    /**
     * 消费者 topic 数组
     */
    private Map<String, String> consumer;

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public Boolean getCleanSession() {
        return cleanSession;
    }

    public void setCleanSession(Boolean cleanSession) {
        this.cleanSession = cleanSession;
    }

    public Integer getTimeout() {
        return timeout;
    }

    public void setTimeout(Integer timeout) {
        this.timeout = timeout;
    }

    public Integer getKeepalive() {
        return keepalive;
    }

    public void setKeepalive(Integer keepalive) {
        this.keepalive = keepalive;
    }

    public Integer getMaxInflight() {
        return maxInflight;
    }

    public void setMaxInflight(Integer maxInflight) {
        this.maxInflight = maxInflight;
    }

    public Integer getQos() {
        return qos;
    }

    public void setQos(Integer qos) {
        this.qos = qos;
    }

    public String getClientInId() {
        return clientInId;
    }

    public void setClientInId(String clientInId) {
        this.clientInId = clientInId;
    }

    public String getClientOutId() {
        return clientOutId;
    }

    public void setClientOutId(String clientOutId) {
        this.clientOutId = clientOutId;
    }

    public Map<String, String> getProducer() {
        return producer;
    }

    public void setProducer(Map<String, String> producer) {
        this.producer = producer;
    }

    public Map<String, String> getConsumer() {
        return consumer;
    }

    public void setConsumer(Map<String, String> consumer) {
        this.consumer = consumer;
    }
}
